package com.cjg.lock;

import java.util.concurrent.TimeUnit;

public class demo03 {
    public static void main(String[] args) throws InterruptedException {
        skiplock skiplock = new skiplock();
        new Thread(()->{
            skiplock.lock();
            try {
                TimeUnit.SECONDS.sleep(5);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                skiplock.unlock();
            }
        },"a").start();
        TimeUnit.SECONDS.sleep(1);

        new Thread(()->{
            skiplock.lock();
            try {
                TimeUnit.SECONDS.sleep(1);
            } catch (InterruptedException e) {
                e.printStackTrace();
            } finally {
                skiplock.unlock();
            }
        },"b").start();

    }
}
